package com.inspur.cloud.controller;

import com.inspur.cloud.entity.dataspace.common.OpEntityResult;
import com.inspur.cloud.entity.dataspace.common.OpResult;
import com.inspur.cloud.service.dataspace.InitializeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dataspace/api/v1/init")
@Api(value = "init", description = "初始化")
public class InitializeController {

    @Autowired
    private InitializeService initializeService;

    @GetMapping("/need")
    @ApiOperation(value = "是否已初始化", notes = "对接人：soff")
    public OpResult need() {
        OpEntityResult<Boolean> result = new OpEntityResult();
        result.setData(initializeService.checkInitialized());
        result.setMsg("查询成功");
        result.setCode(1);
        return result;
    }

    @GetMapping("/oper")
    @ApiOperation(value = "初始化操作", notes = "对接人：soff")
    public OpResult oper() {
        OpResult result = new OpResult();
        initializeService.initial();
        result.setMsg("查询成功");
        result.setCode(1);
        return result;
    }

}
